package com.amikomgamedev.labirinhantu.sound;

import org.andengine.audio.music.Music;
import org.andengine.audio.music.MusicFactory;
import org.andengine.audio.music.MusicManager;
import org.andengine.audio.sound.Sound;
import org.andengine.audio.sound.SoundFactory;
import org.andengine.audio.sound.SoundManager;
import org.andengine.ui.activity.BaseGameActivity;

import android.content.Context;

import com.amikomgamedev.labirinhantu.Utils;

public class Sound_Load
	implements
	    Sound_Data_Path,
	    Sound_Define
{
    protected BaseGameActivity m_Activity;

    protected Music	bgm_Menu;

    protected Music[]	bgm_Game	= new Music[3];    
    
    protected Sound[]	sfx_Game	= new Sound[GAME_SFX.length];

    public Sound_Load(Context context)
    {
	m_Activity = (BaseGameActivity) context;
    }

    private MusicManager getMscMan()
    {
	return m_Activity.getMusicManager();
    }

    private SoundManager getSndMan()
    {
	return m_Activity.getSoundManager();
    }

    public void loadMenuBgm()
    {
	try
	{
	    bgm_Menu = MusicFactory.createMusicFromAsset(
		    getMscMan(),
		    m_Activity,
		    MENU_BGM);

	    bgm_Menu.setLooping(true);
	}
	catch (Exception e)
	{
	    Utils.DEBUG(e);
	}
    }

    public void loadGameBgm()
    {
	try
	{
	    for (int i = 0; i < bgm_Game.length; i++)
	    {
		    bgm_Game[i] = MusicFactory.createMusicFromAsset(
			    getMscMan(),
			    m_Activity,
			    GAME_BGM[i]);

		    bgm_Game[i].setLooping(true);
		
	    }
	}
	catch (Exception e)
	{
	    Utils.DEBUG(e);
	}
    }

    public void loadGameSfx()
    {
	try
	{
	    for (int i = 0; i < sfx_Game.length; i++)
	    {
		sfx_Game[i] = SoundFactory.createSoundFromAsset(
			getSndMan(),
			m_Activity,
			GAME_SFX[i]);
	    }
	}
	catch (Exception e)
	{
	    Utils.DEBUG(e);
	}
    }
}
